home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Softshoe / Lisa's Mac Parts / Views / Canvas Loops / CanvasScreenLoop.cp < prev    next >
Text File  |  2000-06-23  |  874b  |  49 lines

  1. // CanvasScreenLoop.cp
  2.  
  3. #ifndef CanvasScreenLoop_h
  4. #include "CanvasScreenLoop.h"
  5. #endif
  6. #ifndef GrafPortObject_h
  7. #include "GrafPortObject.h"
  8. #endif
  9.  
  10. void CanvasScreenLoop::AdvanceUntilVisible()
  11.   {
  12.     for ( ; Unfinished(); screen++ )
  13.       {
  14.         Rectangle screenBounds( screen->Bounds() );
  15.         screenBounds += parent.Port().GlobalToLocal();
  16.         
  17.         if ( !screenBounds.Intersects( parent.OnScreen() ) )
  18.             continue;
  19.         
  20.         canvas.RestrictOnScreen( screenBounds );
  21.         
  22.         if ( !canvas.Visible() )
  23.           {
  24.             canvas = parent;
  25.             continue;
  26.           }
  27.         
  28.         canvasMaintainer.Use( canvas );
  29.         break;
  30.       }
  31.  
  32.     canvasMaintainer.UseNone();
  33.   }
  34.  
  35. CanvasScreenLoop::CanvasScreenLoop( const Canvas& theParent )
  36.   : parent( theParent ),
  37.      canvas( theParent )
  38.   {
  39.     AdvanceUntilVisible();
  40.   }
  41.  
  42. void CanvasScreenLoop::operator++()
  43.   {
  44.     Assert( Unfinished() );
  45.     screen++;
  46.     canvas = parent;
  47.     AdvanceUntilVisible();
  48.   }
  49.